﻿using Reader.Chromely.Core.Logging;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace Reader.Core.Chromely.Core.ProcessMessage
{
    public class ProcessMessageController
    {
        public string Name
        {
            get
            {
                var attributeInfo = GetAttributeInfo();
                if (attributeInfo != null)
                {
                    return attributeInfo.Item1;
                }
                return string.Empty;
            }
        }
        public List<string> ActionList { get; }
        public ProcessMessageController()
        {
            ActionList = new List<string>();
        }
        private Tuple<string> GetAttributeInfo()
        {
            try
            {
                var attribute = GetType().GetCustomAttribute<ProcessMessagePropertyAttribute>(true);
                if (attribute != null)
                {
                    return new Tuple<string>(attribute.Name);
                }
                return null;
            }
            catch (Exception exception)
            {
                Logger.Instance.Log.Error(exception);
            }

            return null;
        }
    }
}
